package com.company.myfirstjmixproject.entity;

import com.company.myfirstjmixproject.entity.enums.ProdTypeEnum;
import io.jmix.core.entity.annotation.JmixGeneratedValue;
import io.jmix.core.metamodel.annotation.InstanceName;
import io.jmix.core.metamodel.annotation.JmixEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.UUID;

@JmixEntity
@Table(name = "TEST_CREATE_ENTITY_TWO")
@Entity
public class TestCreateEntityTwo {
    @JmixGeneratedValue
    @Column(name = "ID", nullable = false)
    @Id
    private UUID id;

    @Column(name = "TEST_CODE", nullable = false)
    private String testCode;

    @Column(name = "TEST_NAME", nullable = false)
    @InstanceName
    private String testName;

    @Column(name = "QTY", nullable = false)
    private BigDecimal qty;

    @Column(name = "TEST_TYPE", nullable = false)
    private String testType;

    public ProdTypeEnum getTestType() {
        return testType == null ? null : ProdTypeEnum.fromId(testType);
    }

    public void setTestType(ProdTypeEnum testType) {
        this.testType = testType == null ? null : testType.getId();
    }

    public String getTestCode() {
        return testCode;
    }

    public void setTestCode(String testCode) {
        this.testCode = testCode;
    }

    public String getTestName() {
        return testName;
    }

    public void setTestName(String testName) {
        this.testName = testName;
    }

    public BigDecimal getQty() {
        return qty;
    }

    public void setQty(BigDecimal qty) {
        this.qty = qty;
    }

    public UUID getId() {
        return id;
    }

    public void setId(UUID id) {
        this.id = id;
    }
}